<?php
/**
 * Created by PhpStorm.
 * User: apple
 * Date: 2018/7/22
 * Time: 下午7:44
 */
namespace PddWechat\Models\Pos\Service;

use Dai\Framework\Base\BaseService;
use Dai\Framework\Base\BaseSessionInfo;
use Dai\Framework\Library\Log;
use PddWechat\Models\Pos\Data\PostInviteData;
use PddWechat\Models\Pos\Response\IsApplyResponse;


class Isapply extends BaseService
{
    public function __construct()
    {
        $this->postInvateData = new PostInviteData();
    }

    public function execute($basePageInfo)
    {
        /** @var BaseSessionInfo $sessionData */
        $sessionData = $basePageInfo->sessionInfo;
        $openid = $sessionData->openId;
        $postInvateInfo = $this->postInvateData->getApplyInfoByOpenId($openid);
        $isApplyResponse = new IsApplyResponse();
        $isApplyResponse->isapply = $postInvateInfo != null ? 1 : 0;
        Log::info(json_encode($isApplyResponse,true));
        return $isApplyResponse;
    }
}